<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
    <link rel="stylesheet" type="text/css" href="/static/css/reset.css" />
    <link rel="stylesheet" type="text/css" href="/static/css/login.css" />
</head>

<body>
    <div class="pos">
        <div class="login">
            <span class="close iconfont icon-close"></span>
            <img src="/static/img/login/loginlogo.png" alt="">
            <ul>
                <li></li>
                <li class="phone">登陆</li>
                <li></li>
            </ul>
            <form action="tologin" method="post" id="form">
                <input style="margin-top: 0;" type="text" name="username" class="tel" id="username" placeholder="请输入用户名">
                <input type="password" name="password" class="pass" id="password" placeholder="请输入密码">
                <!-- <span class="tips">密码或账号不对</span> -->
                <button class="loginbtn" type="submit" id="bt">
                    登陆
                </button>
            </form>
            <p>
                <span>
                    还没有账号?
                    <a href="javascript:;">点击注册</a>
                </span>
            </p>
        </div>
    </div>
    
</body>
</html>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
    $("#bt").on("click",(event)=>{
         event.preventDefault();    //阻止浏览器默认行为
         $.ajax({
             type:"post",
             url:"/dologin",
             data:{
                 username:$("#username").val(),
                 password:$("#password").val()
             },
             dataType:"json",
             success(response){
                 console.log(response);
                if(response.code == 200){
                    alert(response.msg);
                }else{
                    alert(response.msg);
                }
             },
            error(err){

            }
         })
    })
</script>